import wx
import time

class MyFrame(wx.Frame):
    def __init__(self):
        super().__init__(None, title = '进度条', size = (500, 800))
        panel = wx.Panel(self)
        # 进度条对象
        self.gauge = wx.Gauge(panel, range = 100)
        # gauge.SetValue(10)  # 进度条完成10 / 100
        btn = wx.Button(panel, label = '开始')
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(btn)
        hbox.Add(self.gauge)
        panel.SetSizer(hbox)
        btn.Bind(wx.EVT_BUTTON, self.on_start)
        self.Show()

    def on_start(self, event):
        count = 1
        while True:
            # 休眠0.1秒
            time.sleep(0.1)
            self.gauge.SetValue(count)
            count += 1
            if count > 100:
                print('进度已完成')
                break

app = wx.App()
window = MyFrame()
app.MainLoop()

